<?php
namespace app\index\controller;

use think\console\command\make\Controller;
use think\Db;
use think\Request;
use think\Session;
class Index extends Controller
{
    public function index()
    {
        return view('login');
    }
    public function dologin(){
        $username=Request::instance()->param('username');
        $userpwd=Request::instance()->param('userpwd');
        $res = Db::table('users')->where(['u_name'=>$username])->find();
        if($res){
            if($res['u_pwd']==$userpwd){
                Session::set('name',$res,'think');
                return ['code'=>2,'msg'=>'登录成功'];
            }else{
                return ['code'=>1,'msg'=>'密码错误'];
            }
        }else{
            return ['code'=>0,'msg'=>'账号错误'];
        }
    }

}
